package com.example.resourceSharingPlatform.service;

import com.example.resourceSharingPlatform.config.security.jwt.JwtTokenUtils;
import com.example.resourceSharingPlatform.dao.ItemDao;
import com.example.resourceSharingPlatform.entity.Item;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ItemService {
    @Autowired
    private ItemDao itemDao;

    public Item queryItemById(int id){
        return itemDao.queryItemById(id);
    }

    public List<Item> queryItemByOwnerId(String owner_id){
        return itemDao.queryItemsByOwnerId(owner_id);
    }

    public List<Item> queryItemByName(String name){
        return itemDao.queryItemByName(name);
    }

    public List<Item> queryItemByType(String type){
        return itemDao.queryItemByType(type);
    }

    public List<Item> queryItemByBorrowState(String borrow_state, String type){
        return itemDao.queryItemByBorrowState(borrow_state, type);
    }

    public List<Item> queryAll(){
        return itemDao.queryAll();
    }

    public Item insertItem(Item item){
        item.setBorrow_state("allow_borrow");
        item.setCheck_state("checked");
        return itemDao.insertItem(item);
    }

    public boolean deleteItemById(int id){
        return itemDao.deleteItemById(id);
    }

    public boolean updateItem(Item item){
        return itemDao.updateItem(item);
    }
}
